//
//  NSArrayAdditions.m
//  MapEdit
//
//  Created by Steven Canfield on 7/12/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "NSArrayAdditions.h"

@implementation NSArray (NSArrayAdditions)
+ (NSArray *)arrayWithSTRData:(NSData *)data {
	NSMutableArray * array = [NSMutableArray array];
	
	chk_str_t str;
	
	int dataIndex = 0;
	[data getBytes:&str range:NSMakeRange( dataIndex, sizeof( chk_str_t ))];
	int strIndex;
	for( strIndex = 0; strIndex < str.count; strIndex++ ) {
		[array addObject:[NSString string]];
	}
	
	char * dataBytes = (char *)[data bytes];
	
	for( strIndex = 0; strIndex < str.count; strIndex++ ) {
		int offset = str.offset[ strIndex ];
		NSString * buffer = [NSString stringWithCString:&dataBytes[ offset ] encoding:NSASCIIStringEncoding];
		[array replaceObjectAtIndex:strIndex withObject:buffer];
	}
	
	return array;
}
@end
